<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // var arr = ['red', 'pink', 'orange', 'green', 'yellow', 'blue', 'brown'];
        // arr.forEach(function (value) {
        //     if (value == 'green') {
        //         console.log('找到该元素');
        //         return true;//在foreach里面return不会弄停止迭代
        //     }
        //     console.log(11)
        // })
        var arr = ['red', 'green', 'blue', 'brown']
        arr.some(function (value) {
            if (value == 'green') {
                console.log('找到该元素')
                return true; //在some里面遇到 return true就是直接终结遍历，相对于foreach而言，更方便
            }
            console.log('11')
        })
    </script>
</body>

</html>